/* Project am_R01
Infrared controller PIC16F628A
*/

//#include <pic.h>
#define _LEGACY_HEADERS // 旧バージョンのプログラムで記述
#include <htc.h> // 旧バージョンのプログラムで記述


__CONFIG(
INTIO
& UNPROTECT
& LVPDIS
& BORDIS
& MCLRDIS
& WDTDIS
& PWRTEN
);

__IDLOC(628A);

#define h RB5
#define M1 RA0
#define M2 RA1
#define M3 RA3
#define M4 RA2



void main(void){
unsigned char i,n;

CMCON = 0b00000111;

PORTB = 0;
TRISB = 0b00100000;
PORTA = 0;
TRISA = 0b00000000;

OPTION = 0b10000100;


M1 = 0; M2 = 0; M3 = 0; M4 = 0;


while(1){

TMR0 = 0;
while(TMR0 < 70){
if(h) TMR0 = 0;
}

while(h == 0);
TMR0 = 0;
while(TMR0 < 155);




n = 0;
for(i = 0; i < 20; i++){
TMR0 = 0;
while(TMR0 < 5);
if(h) n = n + 1;
}
if(n > 8){
M1 = 1; M2 = 0; M3 = 0; M4 = 1;
}



n = 0;
for(i = 0; i < 20; i++){
TMR0 = 0;
while(TMR0 < 5);
if(h) n = n + 1;
}
if(n > 8){
M1 = 1; M2 = 0; M3 = 1; M4 = 0;
}



n = 0;
for(i = 0; i < 20; i++){
TMR0 = 0;
while(TMR0 < 5);
if(h) n = n + 1;
}
if(n > 8){
M1 = 0; M2 = 1; M3 = 0; M4 = 1;
}


n = 0;
for(i = 0; i < 20; i++){
TMR0 = 0;
while(TMR0 < 5);
if(h) n = n + 1;
}
if(n > 8){
M1 = 0; M2 = 1; M3 = 1; M4 = 0;
}






for(i = 0; i < 50; i++){
TMR0 = 0;
while(TMR0 < 255);
}

M1 = 0; M2 = 0; M3 = 0; M4 = 0;


}

}


           戻る